using System;
using System.ComponentModel;
using System.Drawing.Design;
using DevExpress.Accessibility;
using DevExpress.Utils.Editors;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Drawing;
using DevExpress.XtraEditors.Registrator;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraEditors.ViewInfo;

namespace Comteck.Winforms.Controls {
  /// <summary>
  /// 
  /// </summary>
  [ToolboxItem(true)]
  public class MyCheckEdit : CheckEdit {

    static MyCheckEdit() {
      RepositoryItemMyCheckEdit.Register();
    }

    /// <summary>
    /// 
    /// </summary>
    public MyCheckEdit() : base() {
      Initialize();
    }

    /// <summary>
    /// 初始化界面
    /// </summary>
    private void Initialize() {
    }


    #region fields

    /// <summary>
    /// 
    /// </summary>
    public override string EditorTypeName => RepositoryItemMyCheckEdit.EditorName;

    /// <summary>
    /// 
    /// </summary>
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public new RepositoryItemMyCheckEdit Properties => base.Properties as RepositoryItemMyCheckEdit;

    ////
    //// 摘要:
    ////     Gets or sets whether focus is moved to the next control (according to the tab
    ////     order) when an end-user presses ENTER.
    //[DefaultValue(true)]
    ////[DevExpressXtraEditorsLocalizedDescriptionAttribute("BaseEditEnterMoveNextControl")]
    //[DXCategory("Behavior")]
    //public override bool EnterMoveNextControl { get; set; } = true;

    #endregion
  }

  /// <summary>
  /// 
  /// </summary>
  [DXCategory("Properties")]
  [UserRepositoryItem("Register")]
  [ToolboxItem(true)]
  public class RepositoryItemMyCheckEdit : RepositoryItemCheckEdit {

    /// <summary>
    /// 
    /// </summary>
    static RepositoryItemMyCheckEdit() {
      Register();
    }

    /// <summary>
    /// 
    /// </summary>
    public RepositoryItemMyCheckEdit() {
    }

    /// <summary>
    /// 
    /// </summary>
    internal const string EditorName = nameof(MyCheckEdit);

    /// <summary>
    /// 
    /// </summary>
    public override string EditorTypeName => EditorName;

    /// <summary>
    /// Gets or sets a value that corresponds to the checked state.
    /// </summary>
    [DefaultValue(1)]
    [DXCategory("Behavior")]
    [Editor(typeof(UIObjectEditor), typeof(UITypeEditor))]
    [TypeConverter(typeof(ObjectEditorTypeConverter))]
    public new object ValueChecked { get; set; } = 1;

    /// <summary>
    /// Gets or sets a value that corresponds to the unchecked state.
    /// </summary>
    [DefaultValue(0)]
    [DXCategory("Behavior")]
    [Editor(typeof(UIObjectEditor), typeof(UITypeEditor))]
    [TypeConverter(typeof(ObjectEditorTypeConverter))]
    public new object ValueUnchecked { get; set; } = 0;

    //
    // 摘要:
    //     Gets or sets whether value scrolling via the Mouse Wheel is supported by the
    //     editor.
    [Browsable(false)]
    [DefaultValue(false)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    [DXCategory("Behavior")]
    [EditorBrowsable(EditorBrowsableState.Never)]
    public override bool AllowMouseWheel { get; set; } = false;

    /// <summary>
    /// 
    /// </summary>
    public static void Register() {
      EditorRegistrationInfo.Default.Editors.Add(
        new EditorClassInfo(
          EditorName, // 
          typeof(MyCheckEdit),
          typeof(RepositoryItemMyCheckEdit),
          typeof(CheckEditViewInfo),
          new CheckEditPainter(),
          true,
          null,
          typeof(CheckEditAccessible)));
    }
  }

}
